import Vue from 'vue'
import Router from 'vue-router'
import Home from '@/pages/home/Home'

import City from '@/pages/city/City'
import Detail from '@/pages/detail/Detail'

// @指代src目录 可在bulild/webpack.base.conf.js中进行配置

Vue.use(Router)

export default new Router({
    routes: [{
            path: '/',
            name: 'Home',
            component: Home
        },
        {
            path: '/city',
            name: 'City',
            component: City
        },
        {
            path: '/detail/:id', // :id 动态路由
            name: 'Detail',
            component: Detail
        }
    ],
    //                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             vue-router 滚动行为
    // 每次做路由切换，让新进页面滚到最顶部
    scrollBehavior(to, from, savedPosition) {
        return { x: 0, y: 0 }
    }
})